/*
** basics2.c for my_printf in /home/nadali_t//local/svn/tek2ed/my_printf
** 
** Made by thomas nadalie
** Login   <nadali_t@epitech.net>
** 
** Started on  Sun Nov 18 16:35:33 2012 thomas nadalie
** Last update Sun Nov 18 18:03:33 2012 thomas nadalie
*/

#include	<stdlib.h>
#include	<unistd.h>
#include	"my.h"

void		my_put_nbr(int nb)
{
  if (nb < 0)
    {
      my_putchar('-');
      nb = nb * -1;
    }
  if (nb > 9)
    my_put_nbr(nb / 10);
  my_putchar((nb % 10) + 48);
}

void            my_bzero(char *b, size_t size)
{
  int           i;

  i = 0;
  while (i < size)
    b[i++] = '\0';
}

char            *my_strdup(const char *src)
{
  char          *dest;
  int           i;

  i = 0;
  if ((dest = malloc((my_strlen(src) + 1) * sizeof(*dest))) == NULL)
    return (NULL);
  my_bzero(dest, my_strlen(src) + 1);
  while (src[i])
    {
      dest[i] = src[i];
      i++;
    }
  dest[i] = '\0';
  return (dest);
}

void		my_put_error(char *str)
{
  write(2, str, my_strlen(str));
}

void		my_showtab(char **tab)
{
  int		i;

  i = 0;
  while (tab[i])
    {
      my_putstr(tab[i++]);
      my_putchar('\n');
    }
}
